<!DOCTYPE html>
<html>

<head>
    <title>北京站网格化系统</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Fonts -->
    <!-- CSS Libs -->
    <link rel="stylesheet" type="text/css" href="../lib/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/animate.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/bootstrap-switch.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/checkbox3.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/jquery.dataTables.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/dataTables.bootstrap.css">
    <!-- <link rel="stylesheet" type="text/css" href="../lib/css/select.bootstrap.min.css"> -->
    <link rel="stylesheet" type="text/css" href="../lib/css/select2.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/jquery.datetimepicker.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/validform.min.css">
    <!-- CSS App -->
    <link rel="stylesheet" type="text/css" href="../lib/css/common/style.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/common/themes/flat-blue.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/common/newstyle.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/baseCommon.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/zc-common.css">    
</head>

<body class="flat-blue">
    <div class="app-container expanded">
        <div class="row content-container">
            <nav class="navbar navbar-default navbar-fixed-top navbar-top">
                <div class="container-fluid app-header">
                    <div class="navbar-header">
                        <button type="button" class="navbar-expand-toggle fa-rotate-90">
                            <i class="fa fa-bars icon"></i>  
                        </button>
                        <top-nav></top-nav>
                    </div>
                    <right-info></right-info>
                </div>
            </nav>
            <div class="side-menu-wrap">
                <side-menu></side-menu>
            </div>
            <!-- Main Content -->
            <div class="container-fluid">
                <div class="side-body padding-top">
                    <div class="row">
                        <div class="col-sm-12">
                            <div class="card card_list">
                                <div class="elm-wrap nav">
                                    <button type="button" class="btn btn-info" onclick="editing('train')">添加车次</button>
                                    <form class="form-inline navbar-right mgr0">
                                        <div class="form-group">
                                          <label for="search_name">车次：</label>
                                          <input type="text" id='search_name' class="form-control search_name" name="search_name" placeholder="请输入车次">
                                        </div>
                                        <button type="button" class="btn btn-info" onclick="searching('train')"  style="margin-left:10px">搜索</button>
                                      </form>
                                </div>
                                <div class="elm-wrap">
                                    <div class="row train-list trainlistvue">
                                        <div class="col-sm-12">
                                            <dl class="row no-gap train-tit">
                                                <dt class="col-sm-2">车次</dt>
                                                <dt class="col-sm-3">出发站<br/>到达站</dt>
                                                <dt class="col-sm-3">出发时间<br />到达时间</dt>
                                                <dt class="col-sm-offset-3 col-sm-1">操作</dt>
                                            </dl>
                                            <dl class="row no-gap train-elm" v-for="(info,index) in datas">
                                                <dd class="col-sm-2 train-name train-singleline">{{info.train_number}}</dd>
                                                <dd class="col-sm-3 train-info">
                                                    <div>
                                                        <i class="begin">始</i>
                                                        <p class="">{{info.train_begin_station_name}}</p>	
                                                    </div>
                                                    <div>
                                                        <i class="end">终</i>
                                                        <p>{{info.train_end_station_name}}</p>	
                                                    </div>
                                                </dd>
                                                <dd class="col-sm-3">
                                                    <div>
                                                        <p>{{info.train_begin_time}}</p>	
                                                    </div>
                                                    <div>
                                                        <p>{{info.train_end_time}}</p>	
                                                    </div>
                                                </dd>
                                                <dd class="col-sm-offset-3 col-sm-1 train-singleline train-do">
                                                    <a href="javascript:void(0)" class="" v-on:click="vueEditing(info)">编辑</a>
                                                    <a href="javascript:void(0)" class="" v-on:click="vueDeling(info)">删除</a>
                                                </dd>
                                            </dl>
                                            
                                        </div>
                                        
                                    </div>
                                    <div class="table_page">

                                    </div>
                                     
                                </div> 
                            </div>
                            <div class="card card_edit">
                                <div class="row">
                                    <div class="col-sm-10">
                                        <div class="elm-wrap">
                                        <form style="" class="trainvue ss_form">
                                        <div class="form-horizontal elm-card">
                                            <p class="title elm-title">车次信息</p>
                                            <div class="form-group">
                                                <label for="train_number" class="col-sm-2 control-label">车次 </label>
                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control train_number" id="train_number" name="train_number" datatype="*" errormsg="请填写正确的车次" nullmsg="车次是必填的" placeholder="请输入车次信息" v-model="info.train_number">
                                                    <span class='Validform_checktip' />
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label for="train_begin_station_id" class="col-sm-2 control-label">始发站： </label>
                                                <div class="col-sm-3">
                                                    <select name="train_begin_station_id" id="train_begin_station_id" class="form-control train_begin_station_id train_station" style="width:100%" datatype="*" errormsg="请选择始发站" nullmsg="请选择始发站" placeholder="请选择始发站"></select>
                                                    <span class='Validform_checktip' />
                                                </div>
                                                <label for="train_begin_time" class="col-sm-2 control-label">始发时间： </label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="train_begin_time" id="train_begin_time" class="form-control train_begin_time datetime" placeholder="请选择始发时间" datatype="*" errormsg="请选择始发时间" nullmsg="请选择始发时间"/>
                                                    <span class='Validform_checktip' />    
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label for="train_begin_station_id" class="col-sm-2 control-label">终点站： </label>
                                                <div class="col-sm-3">
                                                    <select name="train_end_station_id" id="train_end_station_id" class="form-control train_end_station_id train_station" style="width:100%" datatype="*" errormsg="请选择终点站" nullmsg="请选择终点站" placeholder="请选择终点站"></select>
                                                    <span class='Validform_checktip' />
                                                </div>
                                                <label for="train_begin_time" class="col-sm-2 control-label">到达时间： </label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="train_end_time" id="train_end_time" class="form-control train_end_time datetime" datatype="*" errormsg="请选择到达时间" nullmsg="请选择到达时间" placeholder="请选择到达时间" />
                                                    <span class='Validform_checktip' />
                                                </div>
                                            </div>
                                            <!-- <div class="form-group">
                                                <label for="train_in_time" class="col-sm-2 control-label">车体进站时间： </label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="train_in_time" id="train_in_time" class="form-control train_in_time datetime" datatype="*" errormsg="请选择到达时间" nullmsg="请选择到达时间" placeholder="请选择进站时间" />
                                                    <span class='Validform_checktip' />
                                                </div>
                                                <label for="train_out_time" class="col-sm-2 control-label">车体离站时间： </label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="train_out_time" id="train_out_time" class="form-control train_out_time datetime" datatype="*" errormsg="请选择离站时间" nullmsg="请选择离站时间" placeholder="请选择离站时间" />
                                                    <span class='Validform_checktip' />
                                                </div>
                                            </div> -->
                                            <div class="form-group">
                                                <label for="train_ago_number" class="col-sm-2 control-label">交车前车次： </label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="train_ago_number" id="train_ago_number" class="form-control train_ago_number" placeholder="交车前车次" v-model="info.train_ago_number" />
                                                </div>
                                                <label for="train_back_number" class="col-sm-2 control-label">交车后车次： </label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="train_back_number" id="train_back_number" class="form-control train_back_number" placeholder="交车后车次" v-model="info.train_back_number" />
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-horizontal elm-card">
                                            <p class="title elm-title">接发车作业配置</p>
                                            <div class="form-group">
                                                <label for="train_type_id" class="col-sm-2 control-label">列车所属类型： </label>
                                                <div class="col-sm-3">
                                                    <select name="train_type_id" id="train_type_id" class="form-control train_type_id" style="width:100%" datatype="select2" errormsg="请选择列车所属类型" nullmsg="请选择列车所属类型"></select>
                                                    <span class='Validform_checktip' />
                                                </div>
                                                <label for="train_style_id" class="col-sm-2 control-label">车种： </label>
                                                <div class="col-sm-3">
                                                    <select name="train_style_id" id="train_style_id" class="form-control train_style_id" style="width:100%" datatype="select2" errormsg="请选择车种" nullmsg="请选择车种"></select>
                                                    <span class='Validform_checktip' />
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label for="track_id" class="col-sm-2 control-label">列车停靠股道： </label>
                                                <div class="col-sm-3">
                                                    <select name="track_id" id="track_id" class="form-control track_id" style="width:100%" datatype="select2" errormsg="请选择列车停靠股道" nullmsg="请选择列车停靠股道"></select>
                                                    <span class='Validform_checktip' />
                                                </div>
                                                <label for="platform_id" class="col-sm-2 control-label">所属站台 </label>
                                                <div class="col-sm-3">
                                                    <select name="platform_id" id="platform_id" class="form-control platform_id" style="width:100%" datatype="select2" errormsg="请选择列车所属站台" nullmsg="请选择列车所属站台"></select>
                                                    <span class='Validform_checktip' />
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label for="train_depart_cycle" class="col-sm-2 control-label">发车周期： </label>
                                                <div class="col-sm-3">
                                                    <select name="train_depart_cycle" id="train_depart_cycle" class="form-control train_depart_cycle" v-model="info.train_depart_cycle">
                                                        <option value="1">每天</option>
                                                        <option value="2">隔天</option>
                                                        <option value="3">每周</option>
                                                        <option value="4">开一停二</option>
                                                        <option value="5">开二停一</option>
                                                    </select>
                                                </div>   
                                            </div>
                                            <div class="form-group" v-show="info.train_depart_cycle == 3">
                                                <div class="col-sm-offset-2 col-sm-10">   
                                                    <div class="checkbox3 checkbox-check checkbox-blue checkbox-inline">
                                                        <input type="checkbox" id="checkbox0" v-model="info.train_depart_week" name="train_depart_week" value="0">
                                                        <label for="checkbox0">
                                                            周日
                                                        </label>
                                                    </div>
                                                    <div class="checkbox3 checkbox-check checkbox-blue checkbox-inline">
                                                        <input type="checkbox" id="checkbox1" v-model="info.train_depart_week" name="train_depart_week" value="1">
                                                        <label for="checkbox1">
                                                            周一
                                                        </label>
                                                    </div>
                                                    <div class="checkbox3 checkbox-check checkbox-blue checkbox-inline">
                                                        <input type="checkbox" id="checkbox2" v-model="info.train_depart_week" name="train_depart_week" value="2">
                                                        <label for="checkbox2">
                                                            周二
                                                        </label>
                                                    </div>
                                                    <div class="checkbox3 checkbox-check checkbox-blue checkbox-inline">
                                                        <input type="checkbox" id="checkbox3" v-model="info.train_depart_week" name="train_depart_week" value="3">
                                                        <label for="checkbox3">
                                                            周三
                                                        </label>
                                                    </div>
                                                    <div class="checkbox3 checkbox-check checkbox-blue checkbox-inline">
                                                        <input type="checkbox" id="checkbox4" v-model="info.train_depart_week" name="train_depart_week" value="4">
                                                        <label for="checkbox4">
                                                            周四
                                                        </label>
                                                    </div>
                                                    <div class="checkbox3 checkbox-check checkbox-blue checkbox-inline">
                                                        <input type="checkbox" id="checkbox5" v-model="info.train_depart_week" name="train_depart_week" value="5">
                                                        <label for="checkbox5">
                                                            周五
                                                        </label>
                                                    </div>
                                                    <div class="checkbox3 checkbox-check checkbox-blue checkbox-inline">
                                                        <input type="checkbox" id="checkbox6" v-model="info.train_depart_week" name="train_depart_week" value="6">
                                                        <label for="checkbox6">
                                                            周六
                                                        </label>
                                                    </div>
                                                    <span class='weekserror Validform_checktip' />
                                                </div>
                                                
                                            </div>
                                            <div class="form-group">
                                                <label for="start_time" class="col-sm-2 control-label">起始时间： </label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="start_time" id="start_time" class="form-control start_time date" datatype="*" errormsg="请选择起始时间" nullmsg="请选择起始时间" placeholder="请选择起始时间" />
                                                    <span class='Validform_checktip' />
                                                </div>
                                                <label for="finsh_time" class="col-sm-2 control-label">截至时间： </label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="finsh_time" id="finsh_time" class="form-control finsh_time date" placeholder="请选择截止时间" datatype="*" errormsg="请选择截止时间" nullmsg="请选择截止时间"/>
                                                    <span class='Validform_checktip' />
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label for="train_status" class="col-sm-2 control-label">列车状态： </label>
                                                <div class="col-sm-3">
                                                    <select name="train_status" id="train_status" class="form-control train_status" v-model="info.train_status">
                                                        <option value="1">正常</option>
                                                        <option value="2">停运</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label for="train_work_id" class="col-sm-2 control-label">列车作业流程： </label>
                                                <div class="col-sm-3">
                                                    <select name="train_work_id" id="train_work_id" class="form-control train_work_id" style="width:100%"  datatype="select2" errormsg="请选择作业流程" nullmsg="请选择作业流程"></select>
                                                    <span class='Validform_checktip' />
                                                </div>
                                            </div>
                                            
                                        </div>
                                        <div class="form-group" style="margin-top:50px">
                                            <div class="col-sm-offset-2 col-sm-9">
                                                <button type="button" class="btn btn-info edited" onclick="uploadData('train')">确认</button>
                                                <button type="button" class="btn btn-default edit_cancel">取消</button>
                                            </div>
                                        </div>
                                        </form>
                                        </div>
                                    </div>
                                </div>
                                
                            </div> 
                        </div>   
                    </div>
                </div>
            </div>
        </div>
        <footer class="app-footer">
            <div class="wrapper"></div>
        </footer>
        <div class="modal fade" id="modalDel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">删除人员</h4>
                    </div>
                    <div class="modal-body">
                        确定删除人员？
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default cancel" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-info deling">确认</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade" id="modalTips" tabindex="-1" role="dialog" aria-labelledby="myModalLabel3" aria-hidden="true">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel3">提示</h4>
                    </div>
                    <div class="modal-body">
                        温馨提示
                    </div>
                </div>
            </div>
        </div>
    </div>
<!-- Javascript Libs -->
<script type="text/javascript" src="../lib/js/jquery.min.js"></script>
<script type="text/javascript" src="../lib/js/common/base.js"></script>
<script type="text/javascript" src="../lib/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../lib/js/bootstrap-switch.min.js"></script>
<script type="text/javascript" src="../lib/js/jquery.matchHeight-min.js"></script>
<script type="text/javascript" src="../lib/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../lib/js/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="../lib/js/datetimepicker.js"></script>
<script type="text/javascript" src="../lib/js/dataTables.select.min.js"></script>
<script type="text/javascript" src="../lib/js/select2.full.min.js"></script>
<script type="text/javascript" src="../lib/js/validform.js"></script>
<script type="text/javascript" src="../lib/js/depchoice/edep_plugin.js"></script>
<script type="text/javascript" src="../lib/js/ztreeJs.js"></script>
<script type="text/javascript" src="../lib/js/vue.js"></script>
<!-- <script type="text/javascript" src="../lib/js/ace/ace.js"></script>
<script type="text/javascript" src="../lib/js/ace/mode-html.js"></script>
<script type="text/javascript" src="../lib/js/ace/theme-github.js"></script> -->
<!-- Javascript -->
<script type="text/javascript" src="../lib/js/common/app.js"></script>             
<script>
    navData.accNav1 = 'task'
    navData.nav1Name = '作业管理'
    navData.accNav2 = 'task-train'
    navData.accNav3 = '12'
    var navVue = new Vue({
        el:'.side-menu-wrap' 
    })
    var navTopVue = new Vue({
        el:'.app-header' 
    })
    var Info={}
     
    function searching(name){
        var _upData={
            'page':1,
            'train_number':$('.search_name').val(),
        }
        switch(name){
            case 'train':
                trainListInit(_upData)
            break;
        }
    } 
    var trainVue = new Vue({
        el:'.trainvue',
        data:{
            info:{
                train_id:'',
                train_number:'',
                train_ago_number:'',
                train_back_number:'',
                train_depart_cycle:'1',
                train_status:'1',
                train_depart_week:[]
            }
        },
        methods:{
        },
        watch:{
            'info.train_depart_cycle':function(val){
                if(val != '3'){
                    this.info.train_depart_week = []
                }
            },
            'info.train_name':function(val){
                if($.trim(val) != ''){
                    $('.train_back_number').attr('placeholder',val)
                    $('.train_ago_number').attr('placeholder',val)
                }else{
                    $('.train_back_number').attr('placeholder','交车前车次')
                    $('.train_ago_number').attr('placeholder','交车后车次')
                }
                
            }
        }
    })
    function trainListInit(data){
        var _tDatas=$.extend({page:1,_:Math.random()},data)
        $('.side-body').loading('open','加载中')
        $.post(serverUrl.base+serverUrl.taskTrain+'train_list',_tDatas,function(res){
            if(res.code == '0'){
                trainListVue.datas =  res.data 
                $('.table_page').html(res.result_page)
                keydown13($("input.changePage"),function(){
                    $('.btn_page').trigger('click')
                })
                $('.btn_page').text('查找')
            }else{
                alert('没有车次')
                
            }
        },'json').complete(function(res){
            $('body').loading('close')
            $('.side-body').loading('close')
        }).error(function(res){

        })
    }
    //表格翻页 
    //翻页 
    function ajax_data(p){ 
        var _upData={
            'page':p,
            'train_number':$('.search_name').val(),
        } 
        trainListInit(_upData);   
    }
    //翻页 跳转
    function pageIndex(elm){
        var _val = $(elm).prev('input[name=page_index]').val() || $('.changePage').val();
        var p = Number(_val) == NaN?1:Number(_val)
        var _upData={
            'page':p,
            'train_number':$('.search_name').val(),
        } 
        trainListInit(_upData);
    }
    var trainListVue = new Vue({
        el:".trainlistvue",
        data:{
            datas:[],
            count:0
        },
        computed:{
        },
        methods:{
            vueEditing:function(elm){
                
                $.post(serverUrl.base+serverUrl.taskTrain+'train_info',{'train_id':elm.train_id},function(res){
                    if(res.code == '0'){
                        var _tempData = $.extend('',elm,res.data) 
                        editing('train',_tempData)
                    }else{
                        alert('失败')
                    }
                },'json').complete(function(res){
                    

                }).error(function(res){
                    console.log(res)
                })
                
            },
            vueDeling:function(elm){
                $.post(serverUrl.base+serverUrl.taskTrain+'train_info',{'train_id':elm.train_id},function(res){
                    if(res.code == '0'){
                        var _tempData = $.extend('',elm,res.data) 
                        delingModal('train',_tempData)
                    }else{
                        alert('失败')
                    }
                },'json').complete(function(res){
                    

                }).error(function(res){
                    console.log(res)
                })
                
            }
        },
        created:function(){
            trainListInit()
        },
        mounted:function(){
           // newSelectDevice();
        },
        beforeUpdate:function(){
        },
        updated:function(){          
        },
        watch:{
        }
    })
    //编辑
    function editing(name,elm){
        Info={}
        switch(name){
            case 'train':
                $('.card_edit').show()
                $('.card_list').hide()
                Info = {
                    train_number:'',
                    train_ago_number:'',
                    train_back_number:'',
                    train_begin_station_id:'1',
                    train_begin_time:'',
                    train_end_station_id:'1',
                    train_end_time:'',
                    train_in_time:'',
                    train_out_time:'',
                    train_type_id:'1',
                    train_style_id:'1',
                    track_id:'1',
                    platform_id:'1',
                    train_depart_cycle:'1',
                    train_depart_week:[],
                    start_time:'',
                    finsh_time:'',
                    train_status:'1',
                    train_work_id:'1'
                }
                
                $('.Validform_wrong').text('').removeClass('Validform_wrong')
                $('.Validform_error').text('').removeClass('Validform_error')
                $('.select2-selection').css('border-color','#ccc')
                myValidform.resetForm()
                if(arguments[1]){
                    Info = $.extend({},Info,elm)
                }else{
                }
                trainVue.info.train_number=Info.train_number //名字
                trainVue.info.train_ago_number=Info.train_ago_number //交车前车次
                trainVue.info.train_back_number=Info.train_back_number //交车后车次
                trainVue.info.train_depart_cycle=Info.train_depart_cycle //发车周期
                trainVue.info.train_status=Info.train_status //发车周期
                trainVue.info.train_depart_week=Info.train_depart_week //发车周期
                $('.train_begin_station_id').val(Info.train_begin_station_id).trigger('change')
                $('.train_end_station_id').val(Info.train_end_station_id).trigger('change');
                $('.train_begin_time').val(Info.train_begin_time)
                $('.train_end_time').val(Info.train_end_time)
                $('.train_in_time').val(Info.train_in_time)
                $('.train_out_time').val(Info.train_out_time)
                $('.train_type_id').val(Info.train_type_id).trigger('change')
                $('.train_style_id').val(Info.train_style_id).trigger('change')
                $('.track_id').val(Info.track_id).trigger('change')
                $('.platform_id').val(Info.platform_id).trigger('change')
                $('.train_depart_cycle').val(Info.train_depart_cycle)
                $('.train_work_id').val(Info.train_work_id).trigger('change')
                $('.start_time').val(Info.start_time)
                $('.finsh_time').val(Info.finsh_time)
                $('.train_status').val(Info.train_status)
                
            break;
            default:
                $('.card_edit').show()
                $('.card_list').hide()
                Info = {}
            break;
        }
        if(arguments[1]){
            if(name == 'train'){
                Info.rowData = elm
            }else{
                Info.row = $(elm).parents('tr')
            }
            
        }
        
    }
    //删除
    function delingModal(name,elm){
        var _text={
            tit:'删除',
            body1:'确定删除吗？',
            body2:'删除出现问题',
            btn1:'确定',
            cbtn1:'取消',
            cbtn2:'知道了',
            deltit1:'删除成功',
            deltit2:'删除失败',
            delbody1:"删除成功！",
            delbody2:"出现问题",
        },_datas={
            id:'',
            data:{},
            url:''
        }
        switch(name){
            case 'train':
                if(arguments[1]){
                    Info.rowData = elm
                    _datas.data={
                        train_id:Info.rowData.train_id
                    }
                    _text.body1 = '确定删除该车次么？'
                }else{
                    
                }

                _datas.url = serverUrl.base+serverUrl.taskTrain+'del_train'
                _text.tit = '删除车次'
                $('#modalDel').find('.modal-title').text(_text.tit)
                $('#modalDel').find('.modal-body').text(_text.body1)
                $('#modalDel').modal()
            break;
            default:
            break;
        }
        $('.deling').off('click').on('click',function(){
            $('body').loading('open')
            $.post(_datas.url,_datas.data,function(res){
                $('#modalDel').modal('hide')
                if(res.code == 0){
                    setTimeout(function(){
                        $('#modalTips').find('.modal-body').text(_text.deltit1)
                        $("#modalTips").modal()  
                        trainListInit() 
                    },500)
                    
                }else{
                    setTimeout(function(){
                        $('#modalTips').find('.modal-body').text(_text.deltit2)
                        $("#modalTips").modal()    
                    },500)
                }
            },'json').error(function(res){
                $('#modalDel').modal('hide')
                setTimeout(function(){
                    $('#modalTips').find('.modal-body').text(_text.delbody2)
                    $("#modalTips").modal()    
                },500)
            }).complete(function(){
                $('#modalDel').modal('hide')
            })
        })
        
    }  
    //提交 
    function uploadData(name){
        switch(name){
            case 'train':
            var _dataTableRow=trainListVue
            if(!myValidform.check()){
                return false
            }
            var _upData = trainVue.info
            if(_upData.train_depart_cycle == '3' && _upData.train_depart_week.length == 0){
                $('.weekserror').addClass('Validform_wrong').text('请至少选择一天')
                return false
            }else{
                $('.weekserror').removeClass('Validform_wrong').text('')
            }
            
            var upData={
                train_number:_upData.train_number,
                train_ago_number:$.trim($('input[name=train_ago_number]').val()) == ''?_upData.train_number:$.trim($('input[name=train_ago_number]').val()),
                train_back_number:$.trim($('input[name=train_back_number]').val()) == ''?_upData.train_number:$.trim($('input[name=train_back_number]').val()),
                train_begin_station_id:$('select[name=train_begin_station_id]').val(),
                train_begin_time:$('input[name=train_begin_time]').val(),
                train_end_station_id:$('select[name=train_end_station_id]').val(),
                train_end_time:$('input[name=train_end_time]').val(),
                train_in_time:$('input[name=train_end_time]').val(),
                train_out_time:$('input[name=train_begin_time]').val(),
                train_type_id:$('select[name=train_type_id]').val(),
                train_style_id:$('select[name=train_style_id]').val(),
                track_id:$('select[name=track_id]').val(),
                platform_id:$('select[name=platform_id]').val(),
                train_depart_cycle:_upData.train_depart_cycle,
                train_depart_week:_upData.train_depart_week,
                start_time:$('input[name=start_time]').val(),
                finsh_time:$('input[name=finsh_time]').val(),
                train_status:$('select[name=train_status]').val(),
                train_work_id:$('select[name=train_work_id]').val()
            }
            
            if(Info.train_id && Info.train_id != null){
                upData.train_id = Info.train_id
            }
            $('.card_edit').loading('open')
            $.ajax({
                url:serverUrl.base+serverUrl.taskTrain+'edit_train',
                type:"POST",
                data:upData,
                dataType:"json",
                success:function(res){
                    if(res.code == 0){
                        //更新表格
                        // _dataTable.settings()[0].ajax.data={'department_id':Info.department_id}
                        // _dataTable.ajax.reload()
                        var _info='列车信息添加成功！',_text='添加成功'
                        if(Info.row){
                            _info = '列车信息修改成功！'
                            _text = '修改成功'
                        }
                        
                        $("#modalTips").find('.modal-title').text(_text) 
                        $("#modalTips").find('.modal-body').text(_info)
                        $('body').loading('open')
                        trainListInit() 
                        $('.card_edit').hide()
                        $('.card_list').show()
                    }else if(res.code == '2'){
                        $("#modalTips").find('.modal-title').text('出现问题') 
                        $("#modalTips").find('.modal-body').text(res.info)
                    }
                    setTimeout(function(){
                        $("#modalTips").modal()   
                        $("#modalTips").find('.modal-body').text(res.info) 
                    },500)
                },
                complete:function(res){
                    $('#modalDel').modal('hide')
                    $('.card_edit').loading('close')
                },
                error:function(res){
                    $("#modalTips").find('.modal-title').text('出现问题') 
                    $("#modalTips").find('.modal-body').text(res.info)
                    setTimeout(function(){
                        $("#modalTips").modal()    
                    },500)
                }    
            })
            break;
        }
    }
    //取消
    $('.edit_cancel').on('click',function(){
        Info.row && _dataTable && _dataTable.row(Info.row).deselect()
        Info={}
        $('.card_edit').hide()
        $('.card_list').show()
    })
    var myValidform = $(".ss_form").Validform({
        tiptype:3,
        datatype:{
            putso:function(gets,obj,curform,regxp){
                /*参数gets是获取到的表单元素值，
				  obj为当前表单元素，
				  curform为当前验证的表单，
				  regxp为内置的一些正则表达式的引用。*/
                var _checkpwrap = obj.parents('.checkpwrap')
                var _type = _checkpwrap.find('.checkp').val()
                var _userid = _checkpwrap.find('.userid').val()
                var _post = _checkpwrap.find('.post').val()
                var reg1=regxp["*"],
					reg2=/[\d]{7}/,
					mobile=curform.find(".mobile");
                if(obj){
                    if(_type == '1'){
                        //人
                        //console.log(_userid)
                        if(reg1.test(_userid)){return true;}
                    }else if(_type == '3'){
                        //岗位
                        if(reg1.test(_post)){return true;}
                    }
                }
                return false;
            },
            ztreegroup:function(gets,obj,curform,regxp){
                console.log(gets)
                if(gets == ''){
                    return false
                }else{
                }
            },
            select2:function(gets,obj,curform,regxp){
                if(gets.length ==0){
                    obj.siblings('.select2').find('.select2-selection').css('borderColor','red')
                    return false
                }else{
                    obj.siblings('.select2').find('.select2-selection').css('borderColor','#ccc')
                }
            }
        }
    });
    // $(document).on('click','.treegroup',function(){
    //     showsDeptWin(null,'select','dep','depid','emp','single',myValidform);
    // })
   
    function newSelectDevice(ids){
        setTimeout(function(){
            
        },0)

    }
    
    new rpSelect({
        sel:'search_grid',
        url:serverUrl.base+serverUrl.grid+'grid_choice_list',
        multiple:false,
        hasAll:true,
        placeholder:'选择责任网格'
    })
    new rpSelect({
        sel:'train_station',
        url:serverUrl.base+serverUrl.taskTrainStation+'station_list',
        multiple:false,
        placeholder:'选择站名'
    })
    new rpSelect({
        sel:'train_type_id',
        url:serverUrl.base+serverUrl.taskTrain+'train_type_list',
        multiple:false,
        placeholder:'选择列车类型'
    })
    new rpSelect({
        sel:'train_style_id',
        url:serverUrl.base+serverUrl.taskTrain+'train_style_list',
        multiple:false,
        placeholder:'选择车种'
    })
    new rpSelect({
        sel:'track_id',
        url:serverUrl.base+serverUrl.taskTrain+'track_list',
        multiple:false,
        placeholder:'选择股道'
    })
    new rpSelect({
        sel:'platform_id',
        url:serverUrl.base+serverUrl.taskTrain+'platform_list',
        multiple:false,
        placeholder:'选择站台'
    })
    // var _test=1
    $('.train_number').change(function(){
        console.log()
    })
    $('.track_id').change(function(){
        var _val = $(this).val()
        $.post(serverUrl.base+serverUrl.taskTrain+'relation',{_:Math.random(),track_id:_val},function(res){  
            if($('.platform_id').val() != res.data.platform_id){
                $('.platform_id').val(res.data.platform_id).trigger('change')
            }
        },'json')        
    })
    $('.platform_id').change(function(){
        var _val = $(this).val()
        $.post(serverUrl.base+serverUrl.taskTrain+'relation',{_:Math.random(),platform_id:_val},function(res){
            if($('.track_id').val() != res.data.track_id){
                $('.track_id').val(res.data.track_id).trigger('change')
            }
        },'json')
    })
    new rpSelect({
        sel:'train_work_id' ,
        url:serverUrl.base+serverUrl.workTask+'WorkProcessList',
        valide:myValidform,
        multiple:false,
        placeholder:'选择作业流程'
    })
    // new rpSelect({
    //     sel:'train_depart_cycle',
    //     // url:serverUrl.base+serverUrl.taskTrain+'platform_list',
    //     datas:select2Datas.trainCycle,
    //     multiple:false,
    //     placeholder:'选择作业流程'
    // })
    $('.date').datetimepicker({
        timepicker: false,
        format:'Y-m-d',
        minDate:'-1969/12/31'
    }); 
    $('.datetime').datetimepicker({
        datepicker:false,
        timepicker: true,
        format:'H:i',
        step:1
    });
    function keydown13(elm,fn){
        var $elm=elm,$fn=fn
        $elm.on('focus',function(){
            $elm.off('keydown.downs').on('keydown.downs',function() {
                if (event.keyCode == "13") {
                    $fn()
                    $elm.trigger('blur')
                    return false
                }
                
            });
        })
        $elm.on('blur',function(){
            $elm.off('keydown.downs')
        })
    }
    keydown13($("input[name=search_name]"),function(){searching('train')})
    
</script>
</body>

</html>
